Part Number Hot Search : 
RGE500 MBR20 C3171 SR120 07416 WG901401 BF36A1M M5243
Product Description
Full Text Search
 

To Download AN1781 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN1781/0205 1/8 rev. 2 AN1781 application note str71x gpio driving four 7-segment display introduction seven-segment devices are often preferred in di splay applications where high luminescence is required, both for indoor and outdoor applicat ions. segments are marked with letters: a, b, c, d, e, f, g and dp, where dp is the decimal point. the technique described in this note is of a general nature and may be applied to a variety of applications. hardware considerations are reviewed and generation of control software using the str71x is described. 1
2/8 str71x gpio driving four 7-segment display 1 principle of operation a 7-segment display consists of 7 led?s arranged in a figure-eight pattern, then by selectively powering-on various combinations of segments, alphanumeric characters may be displayed; a further led is present which, when powered-on, causes a dot or decimal point to be dis - played (figure 1). the led display can be driven by a common cathode or common anode. with a common cathode display, the common cathode must be connected to the 0v rail and the leds are turned on with a logic one. table 1 illustrates the required segment pattern s for each numeric representation, including the optional decimal point. figure 1. structure of a 7-segment display f a b c d e g dp 2
3/8 str71x gpio driving four 7-segment display table 1. leds turned on for a given digit x = don?t care a b c d e f g dp hex 0 1 1 1 1 1 1 0 x 0x3f 1 0 1 1 0 0 0 0 x 0x06 2 1 1 0 1 1 0 1 x 0x5b 3 1 1 1 1 0 0 1 x 0x4f 4 0 1 1 0 0 1 1 x 0x66 5 1 0 1 1 0 1 1 x 0x6d 6 1 0 1 1 1 1 1 x 0x7d 7 1 1 1 0 0 0 0 x 0x07 8 1 1 1 1 1 1 1 x 0x7f 9 1 1 1 1 0 1 1 x 0x6f a 1 1 1 1 0 1 1 x 0x77 b 0 1 1 1 1 0 1 x 0x7c c 1 0 0 1 1 1 0 x 0x39 d 0 1 1 1 1 0 1 x 0x5e e 1 0 0 1 1 1 1 x 0x79 f 1 0 0 0 1 1 1 x 0x71 dp x x x x x x x 1
4/8 str71x gpio driving four 7-segment display 2 multiplexing four 7-segment led displays 2.1 hardware layout biasing is achieved using the st r71x i/o lines. eight lines (p1.0 - 7) are assigned to led seg - ments a - g and the dp. four lines (p1.8 - 11) are used to drive and select the 7-segment dis - plays through sink transistors (figure 2). figure 2. multiplexing four 7-segments displays 2.2 software implementation biasing can be either continuous or multiplexed as long as the refresh frequency is high enough to ensure image persistence for the human ey e (at least 25 cycles per second to avoid flicker) and it will appear that all the displays are turned on at the same time. as each display is turned on, the appropriate information must be delivered to it so that it will give the correct reading. the multiplexing is achieved by turning on each display for 5 ms duration every 20 ms. this gives an update rate of 50 hz. the 5 ms time-base can be generated using a timer overflow in - terrupt. the main program uses a global pointer which refers to the variable to display. the lower 4 bits correspond to the least significant digit, th e next 4 bits correspond to the second digit and so on. p1.0 p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 p1.8 p1.9 p1.10 p1.11 str71x 4 x 7-segment displays a b c d e f g dp bc 547c bc 547c bc 547c bc 547c 1.2k 1.2k 1.2k 1.2k 0.33k 0.33k 0.33k 0.33k
5/8 str71x gpio driving four 7-segment display depending on which display is selected, and using a hexadecimal to 7-segment display cor - respondence table, the corresponding 4 bits are extracted, then decoded to a 7-segment dis - play and finally sent to the 7-segment led display. the c code given below is for guidance only. the file cannot be used alone, the complete soft - ware can be found at http://www.st.com/mcu #include "71x_lib.h" const u8 b7segmenttable[16] = {0x3f, /* 0 */ 0x06, /* 1 */ 0x5b, /* 2 */ 0x4f, /* 3 */ 0x66, /* 4 */ 0x6d, /* 5 */ 0x7d, /* 6 */ 0x07, /* 7 */ 0x7f, /* 8 */ 0x6f, /* 9 */ 0x77, /* a */ 0x7c, /* b */ 0x39, /* c */ 0x5e, /* d */ 0x79, /* e */ 0x71 /* f */ }; /* pointer to the variable to display */ u16 *pchartodisplay; /* dp to display */ u8 bdp; int main(void) { #ifdef debug debug(); #endif /* set system clock to 32 mhz-------------------------------------------------------*/ /* configure the pll with a multiplication factor = 16 and division factor = 4 */ rccu_pll1config(rccu_mul_16, rccu_div_4); /* set the apb2 clock to default */ rccu_pclkconfig(rccu_default); /* set the rclk to the pll output */ rccu_rclksourceconfig(rccu_pll1_output); /* eic configuration -------------------------------------------------------------- */ /* set the timer 0 irq channel priority to 1 */
6/8 str71x gpio driving four 7-segment display eic_irqchannelpriorityconfig(t0timi_irqchannel, 1); /* enable the timer 0 irq channel interrupts */ eic_irqchannelconfig(t0timi_irqchannel, enable); /* enable irq interrupts */ eic_irqconfig(enable); /* gpio 1 configuration ----------------------------------------------------------- */ /* configure the gpio 1 port to output puch-pull */ gpio_config(gpio1, 0xffff, gpio_out_pp); /* disable all 7-segment displays */ gpio_wordwrite(gpio1, 0); /* tim0 configuration ------------------------------------------------------------- */ /* configure the prescaler to 0x02 to get an overflow interrupt every 5.120 ms this will gives an update rate of 48.8 hz*/ /* inisialize the timer 0 */ tim_init(tim0); /* configure the timer 0 prescaler */ tim_prescalerconfig(tim0, 0x02); /* enable the overflow interrupt */ tim_itconfig(tim0, tim_to_it, enable); /* start the tim0 counter */ tim_counterconfig(tim0, tim_start); /* configure the real time clock */ rtc_prescalerconfig(0x8000); /* get the rtc->cntl register address */ pchartodisplay = (u16 *)rtc->cntl; /* enable the third dp */ bdp = 0x04; /* infinite loop */ while(1); } /******************************************************************************* * function name : t0timi_irqhandler * description : this function handles the timer0 global interrupt. * input : none * output : none * return : none *******************************************************************************/ void t0timi_irqhandler(void) { /* holds the number of the selected 7 -segment display.*/ static u8 displayer = 0x00;
7/8 str71x gpio driving four 7-segment display /* clear timer 0 overflow flag */ tim_flagclear ( tim0 , tim_tof ); /* turn off all 7-segment led displays */ gpio1->pd = 0x0000; /* send the next digit */ gpio_bytewrite(gpio1, gpio_lsb, b7segmenttable[(*pchartodisplay>>(display - er*4))&0x000f]); /* drive the dp of the selected display */ gpio_bitwrite(gpio1, 7, bdp>>displayer); /* turn on the selected 7-segment display */ gpio_bitwrite(gpio1, 8+displayer, 1); /* adjust the number of the next 7-segment display */ displayer++; if (displayer==4) displayer=0; }
8/8 str71x gpio driving four 7-segment display ?the present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connection with their products.? information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without express written approval of stmicroelectro nics. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners ? 2005 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia ? belgium - brazil - canada - china ? czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN1781

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X